package cn.txm.basic.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 这是SpringMVC的配置类，主要用来添加拦截器
 * @author Administrator
 * @version 1.0
 * @date 2021/1/14 10:43
 */
@Configuration
public class WebConfiguration implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")             //拦截所有请求
                .excludePathPatterns("/lr/**","/fastdfs/**","/login/**","/shop","/employee","/dept","/product","/swagger-resources/**","/adopt", "/webjars/**", "/v2/**", "/swagger-ui.html/**","/front/**","/alipay/**");//放行/lr和/fastdfs下面的所有资源请求

    }
}
